<template>
	<view>
		<u-popup :show="popuo_show" round="20rpx" @close="onClose()" mode="bottom"  bgColor="#ffffff" >
			<view class="select-wrap">
				<view class="title-line">
					<text class="title">评价工单</text>
					<image src="@/static/images/close.png" class="close-ioc" @click="onClose()"></image>
				</view>
				<view class="form-view">
					<view class="line">
						<text class="label">售后评价</text>
						<view class="right">
							<view class="rate-view">
								<u-rate :count="5" v-model="rate" inactiveColor="#E6E6E6" activeColor="#FFCC18" size="40rpx" activeIcon="star-fill" inactiveIcon="star-fill"></u-rate>
							</view>

						</view>
					</view>

					<view class="line">
						<text class="label">建议及优化</text>
						<view class="right">
							<view class="line-bg">
								<textarea placeholder="请输入" v-model="text" class="textarea"></textarea>
							</view>
						</view>
					</view>
				</view>

				<view class="btn-view">
					<button class="btn" @click="onSubmit()">保 存</button>
				</view>
			</view>
			<i-toast ref="iToast"></i-toast>
			<u-toast ref="uToast"></u-toast>
		</u-popup>

	</view>
</template>

<script>
	export default {

		data() {
			return {
				popuo_show: false,
				id: null,
				rate: 5,
				text: "",

			};
		},
		methods: {
			show(id) {
				this.id = id
				this.rate = 5
				this.text = ""
				this.popuo_show = true;
			},

			onClose() {
				this.popuo_show = false;
				this.$emit("close");
			},

			onSubmit() {


				const params = {
					id: this.id,
					rate: this.rate,
					text: this.text,
				}
				this.api.post("test", { params: params }).then(res => {
					this.$refs.iToast.show("提交成功")
					setTimeout(() => {
						this.$emit("seccess")
						this.onClose()
					}, 800)
				}).catch(err => {
					this.apiErr(err)
				}).finally(() => {
					this.loadingHide();
				})
			},

		},

	}
</script>

<style lang="scss" scoped>
	.select-wrap {
		display: flex;
		flex-direction: column;

		.title-line {
			position: relative;
			display: flex;
			align-items: center;
			justify-content: center;
			padding: 30rpx;
			border-bottom: 1px solid #E5E5E5;

			.title {
				font-size: 32rpx;
				color: #333333;
			}

			.close-ioc {
				position: absolute;
				right: 30rpx;
				width: 26rpx;
				height: 26rpx;
			}
		}
	}

	.form-view {
		display: flex;
		flex-direction: column;
		background-color: #ffffff;
		padding: 0 30rpx 0rpx;
		margin-top: 10rpx;

		.line {
			display: flex;
			align-items: flex-start;
			margin-top: 26rpx;

			.label {
				line-height: 84rpx;
				font-size: 28rpx;
				color: #333333;
				width: 150rpx;
			}

			.right {
				display: flex;
				flex: 1;

				.line-bg {
					position: relative;
					flex: 1;
					display: flex;
					align-items: center;
					background: #FAFAFA;
					border-radius: 12rpx;


					.textarea {
						padding: 28rpx;
						font-size: 28rpx;
						height: 180rpx;
						width: 100%;
					}
				}

				.rate-view {
					display: flex;
					align-items: center;
					height: 84rpx;
				}
			}
		}

	}

	.btn-view {
		padding: 30rpx 30rpx;
	}
</style>